package Eyjafjalla.event;

import Eyjafjalla.patch.PompeiiPatch;
import Eyjafjalla.relic.ShadowOfPompeii;
import Eyjafjalla.relic.VolcanoBoom;
import Eyjafjalla.relic.VolcanoMask;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.core.Settings;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.events.AbstractImageEvent;
import com.megacrit.cardcrawl.localization.EventStrings;
import com.megacrit.cardcrawl.relics.AbstractRelic;
import com.megacrit.cardcrawl.rooms.AbstractRoom;

public class ALetter extends AbstractImageEvent {
    public static final String ID = "eyjafjalla:ALetter";
    private static final EventStrings eventStrings;
    public static final String NAME;
    public static final String[] DESCRIPTIONS;
    public static final String[] OPTIONS;

    public ALetter(){
        super(NAME,DESCRIPTIONS[0],"EyjafjallaResources/img/events/ALetter.png");
        imageEventText.setDialogOption(OPTIONS[0],new ShadowOfPompeii());
        imageEventText.setDialogOption(OPTIONS[1],new VolcanoMask());
        imageEventText.setDialogOption(OPTIONS[2]);
        currentStage = 0;
    }

    @Override
    public void onEnterRoom() {
        PompeiiPatch.enterEvent = true;
    }

    @Override
    protected void buttonEffect(int i) {
        if(currentStage==0){
            this.imageEventText.clearAllDialogs();
            if(i==0){
                currentStage = 1;
                AbstractDungeon.getCurrRoom().spawnRelicAndObtain((float)(Settings.WIDTH / 2), (float)(Settings.HEIGHT / 2),new ShadowOfPompeii());
                imageEventText.loadImage("EyjafjallaResources/img/events/ALetterTwo.png");
                imageEventText.updateBodyText(DESCRIPTIONS[1]);
                imageEventText.setDialogOption(OPTIONS[3],getRelic());
            }
            else if(i==1){
                currentStage = 1;
                AbstractDungeon.getCurrRoom().spawnRelicAndObtain((float)(Settings.WIDTH / 2), (float)(Settings.HEIGHT / 2),new VolcanoMask());
                imageEventText.loadImage("EyjafjallaResources/img/events/ALetterTwo.png");
                imageEventText.updateBodyText(DESCRIPTIONS[2]);
                imageEventText.setDialogOption(OPTIONS[3],getRelic());
            }
            else {
                currentStage = 2;
                AbstractDungeon.player.heal(10,true);
                imageEventText.updateBodyText(DESCRIPTIONS[3]);
                imageEventText.setDialogOption(OPTIONS[4]);
            }
        }
        else if(currentStage==1){
            this.imageEventText.clearAllDialogs();
            currentStage = 2;
            AbstractDungeon.getCurrRoom().spawnRelicAndObtain((float)(Settings.WIDTH / 2), (float)(Settings.HEIGHT / 2),getRelic());
            imageEventText.updateBodyText(DESCRIPTIONS[4]);
            imageEventText.setDialogOption(OPTIONS[4]);
        }
        else {
            this.openMap();
        }
    }

    int currentStage;

    private AbstractRelic getRelic(){
        AbstractRelic relic = new VolcanoBoom();
        if(AbstractDungeon.actNum==1){
            relic.counter = 50;
        }
        else if(AbstractDungeon.actNum==2){
            relic.counter = 40;
        }
        else if(AbstractDungeon.actNum==3){
            relic.counter = 30;
        }
        else {
            relic.counter =20;
        }
        return relic;
    }


    static {
        eventStrings = CardCrawlGame.languagePack.getEventString(ID);
        NAME = eventStrings.NAME;;
        DESCRIPTIONS = eventStrings.DESCRIPTIONS;
        OPTIONS = eventStrings.OPTIONS;
    }
}
